home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d1 / amac34.arc / INPUT.DOC < prev    next >
Text File  |  1991-02-16  |  4KB  |  101 lines

  1.                          INPUT Ver. 1.0
  2.                        (c) Copyright 1986
  3.                         William C. Parke
  4.                             for CHUG
  5.                    Capitol Heath Users' Group
  6.  
  7.        INPUT  is a  batch file  utility to get console input from
  8. within a  batch file.  There are several variants of this type of
  9. program in  the public domain.  A common type uses the ERRORLEVEL
  10. to pass  a keyboard  response to  a BAT  file.   These  type  are
  11. limited to  a single key transfer.  Another type, such as ANSWER,
  12. written by  Frank Schweiger,  prompts for  a console  input, then
  13. puts the  result into  an Environment Variable.  INPUT is of this
  14. type, but  adds some refinement.  With INPUT, the response string
  15. is set  to upper  case unless  the 'bare'  switch  is  used.    A
  16. linefeed is  sent to  the console  after the  response to allow a
  17. following ECHO  command.  In  addition,  preceding  and  trailing
  18. blanks are  removed in the default mode.  Another option lets the
  19. BAT file define the length of the string used in the response.
  20.  
  21.      The syntax for INPUT is the following:
  22.  
  23.         INPUT prompting string [/b/nn]
  24.  
  25.      Output of this program is placed in the Environment Variable
  26. called ANS.   If  there is  no space left in the Environment, the
  27. ERRORLEVEL is  set to  1.   If a  previous ANS  is found,  it  is
  28. removed and  the new  ANS is placed at the end of the Environment
  29. Variable list.  If there  is no  response to  the  INPUT  prompt,
  30. ERRORLEVEL is  set to  1.   The prompting  string may contain any
  31. standard ASCII  characters except  the dollar  sign and the slash
  32. '/' character.   This  string is displayed on the console as soon
  33. as INPUT  is evoked.  If no string is present, a help display for
  34. the use  of INPUT  is displayed.   The brackets above enclose two
  35. optional parameters.   Either  or both  may be  used.   They  are
  36. defined as:
  37.  
  38.       b = bare input
  39.  
  40.       nn= a truncation number from 1 to 72
  41.  
  42. If the  'b' switch  is used,  then the console response string is
  43. left as  typed and  inserted into the Environment as the variable
  44. ANS. Without  the 'b'  option, a  response string is converted to
  45. upper case, and any preceding or trailing spaces are removed.  If
  46. the 'nn'  truncation number  is used, the console response string
  47. will be  truncated to  length nn before being used to define ANS.
  48. This option  is useful  for insuring  that a  'yes-no' answer  is
  49. properly  handled.    By  using  'nn'=1,  all  of  the  following
  50. responses will give an ANS=Y : 'yes', 'y', ' yes', ' y', ' yes ',
  51. ' y ',  'YES', 'Y', ' YES', ' Y', ' Y ', etc.
  52.  
  53.  
  54. Example fragments from batch file applications:
  55.  
  56. Example 1: Getting yes/no answers:
  57.  
  58.       IF EXIST %1 GOTO OK
  59.       INPUT %1 not found.  Do you wish to go on?  /1
  60.       IF %ANS%==Y GOTO OK
  61.       GOTO EXIT
  62.       :OK
  63.         ...
  64.       :EXIT
  65.       SET ANS=
  66.  
  67.   The last line of this example drops ANS from the Environment,
  68. saving   space for additional variables.
  69.  
  70. Example 2: Getting new path and file names:
  71.  
  72.       INPUT Give new file name:
  73.       SET FILE=%ANS%
  74.       SET ANS=
  75.       ...
  76.  
  77. Note: A space should be added at the end of the colon above.
  78.  
  79. Example 3: Starting a requested program:
  80.  
  81.       ECHO OFF
  82.       :START
  83.       TYPE PROGS.LST
  84.       REM PROGS.LST is an ascii list of programs
  85.       INPUT Enter program and command line, if needed :
  86.       IF ERRORLEVEL=1 GOTO EXIT
  87.       %ANS%
  88.       IF NOT ERRORLEVEL=1 GOTO EXIT
  89.       ECHO Program error.
  90.       ECHO  Please re-enter or type a carriage return.
  91.       GOTO START
  92.       :EXIT
  93.       SET ANS=
  94.  
  95. Note that  the user can exit this BAT by typing a carriage return
  96. in response  to the  INPUT string.   Alternatively, CTRL-C can be
  97. used for the same purpose.
  98.  
  99. Comments may be sent to the author via CHUG, Capital Heath Users'
  100. Group, P.O. Box 16406, Arlington, VA 22215-1406.
  101.